package com.wjl.springcloudalibaba.sentinel.gatewaysentinel.fallback;

import com.alibaba.csp.sentinel.adapter.gateway.zuul.fallback.BlockResponse;
import com.alibaba.csp.sentinel.adapter.gateway.zuul.fallback.DefaultBlockFallbackProvider;
import com.alibaba.csp.sentinel.slots.block.BlockException;

/**
 * @author wjl
 */
public class CustomizedBlockFallbackProvider extends DefaultBlockFallbackProvider {
    @Override
    public BlockResponse fallbackResponse(String route, Throwable cause) {
        if (cause instanceof BlockException) {
            return new BlockResponse(429, "Zuul 被限流了", route);
        } else {
            return new BlockResponse(500, "System Error", route);
        }
    }
}
